<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<include file="Public/header"/>
<body>
<if condition="$data['type'] eq 5">
    <div class="row">
        <div style="width: 50%;margin: 0 auto;">
            <if condition="!empty($data['address_name']) and !empty($data['address'])">
            <form id="form1" method="post">
                <div class="form-group">
                    <label class="control-label">
                        收货人姓名:
                    </label>
                    {$data.consignee}
                </div>
                <div class="form-group">
                    <label class="control-label">
                        收货人手机:
                    </label>
                    {$data.mobile}
                </div>
                <div class="form-group">
                    <label class="control-label">
                        收货省市区:
                    </label>
                    {$data.address_name}
                </div>
                <div class="form-group">
                    <label class="control-label">
                        收货详细地址:
                    </label>
                    {$data.address}
                </div>
                <div class="form-group">
                    <label class="control-label">
                        收货地址标志建筑物:
                    </label>
                    {$data.sign_building}
                </div>
                <div class="form-group">
                    <label class="control-label">
                        发货单号:
                    </label>
                    <input type="text" placeholder="填写发货单号" class="form-control" value="" name="invoice_no">
                </div>
                <div style="padding-left: 90px">
                    <input type="hidden" value="{$data.type}" name="type">
                    <button class="btn btn-primary btn-wide pull-left" type="button" onclick="setInvoice({$data.draw_log_id})">
                        提交 <i class="fa fa-arrow-circle-right"></i>
                    </button>
                </div>
            </form>
                <else />
                <div class="form-group">
                    <label class="control-label">
                        该用户暂未设置收货地址
                    </label>
                </div>
            </if>
        </div>
    </div>
</if>
<!-- 奖品为话费-->
<if condition="$data['type'] eq 3">
    <div class="row">
        <div style="width: 50%;margin: 0 auto;">
            <form id="form2" method="post">
                <div class="form-group">
                    <label class="control-label">
                        用户名:
                    </label>
                    {$data.member_name}
                </div>
                <div class="form-group">
                    <label class="control-label">
                        手机号:
                    </label>
                    {$data.mobile}
                </div>
                <div class="form-group">
                    <label class="control-label">
                        中奖话费:
                    </label>
                    {$data.draw_value}
                </div>
                <div class="form-group">
                    <label class="control-label">
                        充值图片:<span class="symbol required" aria-required="true"></span>
                    </label>
                    <br>
                    <div class="upload_file">
                        <label>
                            <input type="file" name="promotion_photo" class="upload_input" id="recharge_photo" value=""
                                   style="display:none;">
                            <div class="fileinput fileinput-new" data-provides="fileinput">
                                <div class="fileinput-new thumbnail">
                                    <img id="promotion_photo_src"
                                         src="{:U('wap/index/get_thumbs',array('auto'=>300))}?img={$data.recharge_img}"
                                         alt="">
                                </div>
                            </div>
                            点击上传充值图片
                        </label>
                        <input type="hidden" name="recharge_img" id="recharge_img" value="{$data.recharge_img}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">
                        充值单号:
                    </label>
                    <input type="text" placeholder="充值单号" class="form-control" value="" name="recharge_no">
                </div>
                <div class="form-group">
                    <label class="control-label">
                        充值备注:
                    </label>
                    <input type="text" placeholder="充值备注" class="form-control" value="" name="recharge_remark">
                </div>
                <div style="padding-left: 90px">
                    <input type="hidden" value="{$data.type}" name="type">
                    <button class="btn btn-primary btn-wide pull-left" type="button" onclick="setRecharge({$data.draw_log_id})">
                        提交 <i class="fa fa-arrow-circle-right"></i>
                    </button>
                </div>
            </form>
        </div>
    </div>
</if>
<include file="Public/javascript"/>
<script src="__PUBLIC__/bootstrap/vendor/jquery-validation/jquery.validate.min.js"></script>
<script src="__PUBLIC__/bootstrap/vendor/ajaxfileupload/ajaxfileupload.js"></script>
<script type="text/javascript">
    //此函数处理商品发货
    function setInvoice(id){
        var index = parent.layer.getFrameIndex(window.name);
        var type=$('[name="type"]').val();
        var invoice=$('[name="invoice_no"]').val();
//        alert(invoice);
        $('#tips').remove();
        if(invoice !=''){
            $.ajax({
                url: '<?php echo U("admin/Draw/draw_dispose") ?>',
                data: 'id=' + id + '&type=' + type + '&invoice=' + invoice,
                type: 'post',
                dataType: 'json',
                success: function (re) {
                }
            })
            parent.$('#dispose_' + id).remove();
            parent.layer.close(index);
        }else{
            var tips='<span style="color:red" id="tips">请填写发货单</span>';
            $('[name="invoice_no"]').after(tips);
        }
    }
    //此函数处理发货充值
    function setRecharge(id){
        var index = parent.layer.getFrameIndex(window.name);
        var type = $('[name="type"]').val();
        var recharge_img = $('#recharge_img').val();
        var recharge_no = $('[name="recharge_no"]').val();
        var recharge_remark=$('[name="recharge_remark"]').val();
        $('#tips_O').remove();
        $('#tips_T').remove();
        if(recharge_img != "" && recharge_no !="" ){
            $.ajax({
                url:'<?php echo U("admin/Draw/draw_dispose") ?>',
                data:'id='+id+'&type='+type+'&recharge_img='+recharge_img+
                '&recharge_no='+recharge_no+'&recharge_remark='+recharge_remark,
                type:'post',
                dataType:'',
                success:function(re){
                    parent.$('#dispose_'+ id).remove();
                    parent.layer.close(index);
                }
            })
        }else{
            var tips_O = '<span style="color:red" id="tips_O">请上传充值图片</span>';
            var tips_T = '<span style="color:red" id="tips_T">请填写充值单号</span>';
            $('[name="recharge_no"]').after(tips_T);
            $('#recharge_photo').after(tips_O);
        }
    }
    //图片上传,带预览
    $().ready(function(){
        $('.upload_file').on('change','.upload_input',function () {
            ajaxFileUpload();
        })
    })
    function ajaxFileUpload(){
        $.ajaxFileUpload({
            url: '{:U("admin/Imagecat /upload_ajax")}',
            secureuri: false,
            fileElementId: 'recharge_photo',
            dataType: 'json',
            data: {name: 'logan', id: 'id'},
            success: function (data, status) {
                if (typeof (data.error) != 'undefined') {
                    if (data.error != '') {
                        var dialog = art.dialog({title: false, fixed: true, padding: 0});
                        dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                    } else {
                        var resp = data.msg;
                        if (resp != '0000') {
                            var dialog = art.dialog({title: false, fixed: true, padding: 0});
                            dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                            return false;
                        } else {
                            $("#recharge_img").val(data.imgurl);
                            $("#promotion_photo_src").attr('src', data.imgurl);
//                                  art.dialog.open("{:U('admin/Imagecat/index')}?img=" + data.imgurl, {
//                                        title: '裁剪图片',
//                                        width: '605px',
//                                        height: '290px'
//                                    });

                            //dialog.time(3).content("<div class='msg-all-succeed'>上传成功！</div>");
                        }
                    }
                }
            },
            error: function (data, status, e) {
                var dialog = art.dialog({title: false, fixed: true, padding: 0});
                dialog.time(3).content("<div class='tips'>" + e + "</div>");
            }
        })
        return false;
    }
</script>
</body>
</html>